import { useState, useEffect } from 'react'
import axios from 'axios';

function App() {
  // 第一变
  const [data, setData] = useState({hits: []})
  useEffect(async () => {
    

    const fetchData = async () => {
      const result = await axios(
        'https://hn.algolia.com/api/v1/search?query=redux');
      setData(result.data)  
    }
  },[])
  return (
    <ul>
      {data.hits.map(item => (
        <li key={item.ObjectID}>
          <a href="{item.url}">{item.title}</a>
        </li>
      ))}
    </ul>
  )
}

export default App
